package hlhj.fhp.checkpoint.adp

import android.graphics.Color
import android.view.View
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import hlhj.fhp.checkpoint.R
import hlhj.fhp.checkpoint.javaBean.CostBean
import hlhj.fhp.checkpoint.javaBean.ViolationOrderBean

/**
 * Created by Never Fear   on 2018\11\12 0012.
Never More....
 */
class ViolationOrderListAdp(private val datas:ArrayList<ViolationOrderBean.InfoBean.ListBean.DataBean>)
    : BaseQuickAdapter<ViolationOrderBean.InfoBean.ListBean.DataBean, BaseViewHolder>(R.layout.cost_list_item,datas) {
    var listener:OnPayClick?=null
    override fun convert(helper: BaseViewHolder?, item: ViolationOrderBean.InfoBean.ListBean.DataBean?) {
        helper?.setText(R.id.itemTime,"违规日期： ${item?.time}")
        helper?.setText(R.id.itemTitle,"违规事件： ${item?.reason}")
        helper?.setText(R.id.itemContent,"违规内容： ${item?.reason}")
        helper?.setText(R.id.itemAddaress,"违规区域： ${item?.address}")
        helper?.setText(R.id.tvPunnish,"扣${item?.point}分，罚${item?.fine}元")
        helper?.setText(R.id.driver,"驾驶员：${item?.car_owner}")

        val itemStatus = helper?.getView<TextView>(R.id.itemStatus)
        when(item?.status){
            0->{
                itemStatus?.text="未报价"
                helper?.setVisible(R.id.btGoFee,false)
            }
            1->{
                itemStatus?.text="无法代办"
                helper?.setVisible(R.id.btGoFee,false)
            }
            2->{
                itemStatus?.text="代付款"
                helper?.setVisible(R.id.btGoFee,true)
                helper?.setText(R.id.itemMMoney,"${item?.offer}元")
                helper?.getView<View>(R.id.btGoFee)?.setOnClickListener {
                    listener?.click(item?.id,item?.offer,(item?.serviceFee.toDouble()+item?.markFee.toDouble()).toString())
                }
                if (item?.offer_type==1){
                    helper?.getView<View>(R.id.btGoFee)?.background=null
                    helper?.setTextColor(R.id.itemMMoney,Color.parseColor("#FFFF008E"))
                    helper?.getView<TextView>(R.id.itemMMoney)?.setTextSize(14f)
                    helper?.getView<View>(R.id.tvFee)?.visibility=View.GONE
                    helper?.getView<View>(R.id.btGoFee)?.isClickable=false
                }else if (item?.offer_type==2){
                    helper?.getView<View>(R.id.btGoFee)?.background=mContext.resources.getDrawable(R.drawable.btn_jf)
                    helper?.getView<TextView>(R.id.itemMMoney)?.setTextSize(10f)

                    helper?.getView<View>(R.id.tvFee)?.visibility=View.VISIBLE
                    helper?.setTextColor(R.id.itemMMoney,Color.parseColor("#ffffff"))
                    helper?.getView<View>(R.id.btGoFee)?.isClickable=true
                }
            }
            3->{
                itemStatus?.text="处理中"
                helper?.setVisible(R.id.btGoFee,false)
            }
            4->{
                itemStatus?.text="已完成"
                helper?.setVisible(R.id.btGoFee,false)
            }
        }
    }

    interface OnPayClick{
        fun click(id:Int,money:String,offer:String)
    }
}